import { findUp } from '../../../src/config/utils/findUp';
import { expect } from 'chai';
import path from 'path'

describe('findUp util', () => {
  it('searches for file', () => {
    const expectedPath = path.resolve('package.json')
    const actualPath = findUp('package.json');
    expect(actualPath).to.be.equal(expectedPath);
  });

  it('throws if file not found', () => {
    const filename = 'non-existent-file.with-non-existent-extension';
    const failingFunction = () => findUp(filename);
    expect(failingFunction).to.throw(`${filename} not found in any dir above current`);
  });
});
